package com.wgchao.amc.repository.base;

import com.wgchao.amc.entity.base.SysBaseAgency;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @作者  wgchao
 * @时间 2019-10-14 
 * @用途  
 */
@Repository
public interface SysBaseAgencyRepository  extends JpaRepository<SysBaseAgency, String>, JpaSpecificationExecutor<SysBaseAgency> {

    @Query("select max(agencyCode) from SysBaseAgency where parCode=?1")
    public String findNextChildCode(String parentCode);

    public List<SysBaseAgency> findAllByAgencyCodeLike(String agencyCode);

    public List<SysBaseAgency> findAllByAgencyCodeLikeAndDelIsFalseAndCancelIsFalse(String agencyCode, Sort sort);

}
